
package com.hexiang.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

@RestController
public class WebReqWebClientController {

    @Autowired
    private WebClient webClient;

    @GetMapping("/getCall")
    public Mono<String> getCall() {
        String url = "http://www.suning.com";
        return webClient.get().uri(url).retrieve().bodyToMono(String.class);
    }

    @GetMapping("/getCallByEntity")
    public Mono<String> remoteCallByEntity() {
        String url = "http://www.test.com";

        return webClient.get().uri(url).retrieve().bodyToMono(String.class);
    }
}